package com.jy.modules.cims.component.common.service;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jy.modules.cims.data.common.dao.TCMmExcelTemplateDao;
import com.jy.modules.cims.data.common.dto.TCMmExcelTemplateDTO;
import com.jy.platform.core.common.BaseDTO;

/**
 * @classname: TCMmExcelTemplateService
 * @description: 定义  模板信息 实现类
 * @author:  JY-IT-D001
 */
@Service("com.jy.modules.cims.component.common.service.TCMmExcelTemplateService")
public class TCMmExcelTemplateService implements Serializable {

    private static final long serialVersionUID = 1L;
    
	@Autowired
	private TCMmExcelTemplateDao dao;

	/**
     * @author JY-IT-D001
     * @description: 分页查询 T_C_MM_EXCEL_TEMPLATE列表
     * @date 2015-01-06 17:32:59
     * @param searchParams 条件
     * @return
     * @throws
     */ 
	public List<TCMmExcelTemplateDTO> searchTCMmExcelTemplateByPaging(Map<String,Object> searchParams) throws Exception {
		List<TCMmExcelTemplateDTO> dataList =  dao.searchTCMmExcelTemplateByPaging(searchParams);
		return dataList;
	}
	/**
     * @author JY-IT-D001
     * @description: 按条件查询T_C_MM_EXCEL_TEMPLATE列表
     * @date 2015-01-06 17:32:59
     * @param searchParams 条件
     * @return
     * @throws
     */
	public List<TCMmExcelTemplateDTO> searchTCMmExcelTemplate(Map<String,Object> searchParams) throws Exception {
	    List<TCMmExcelTemplateDTO> dataList = dao.searchTCMmExcelTemplate(searchParams);
        return dataList;
    }
	/**
     * @author JY-IT-D001
     * @description: 查询T_C_MM_EXCEL_TEMPLATE对象
     * @date 2015-01-06 17:32:59
     * @param id
     * @return
     * @throws
     */ 
	public TCMmExcelTemplateDTO queryTCMmExcelTemplateByPrimaryKey(String id) throws Exception {
		
		List<TCMmExcelTemplateDTO> dtolist = dao.findTCMmExcelTemplateByPrimaryKey(id);
		
		if(dtolist != null&&dtolist.size()>0) 
			return dtolist.get(0);
		else
			return null;
	}
	
	/**
	 *  
	 * @Title findTCMmExcelTemplateByContractCode
	 * @Description TODO
	 * @param contractCode
	 * @return
	 * @throws Exception 
	 * TCMmExcelTemplateDTO 
	 * @date 2015-2-6-下午6:31:42
	 * @update 
	 * @throws
	 */
	public TCMmExcelTemplateDTO findTCMmExcelTemplateByContractCode(Map<String,Object> searchParams) throws Exception {
		
		TCMmExcelTemplateDTO dto = dao.findTCMmExcelTemplateByContractCode(searchParams);
		
		if(dto == null) dto = new TCMmExcelTemplateDTO();
		
		return dto;
		
	}
	
	/**
	 *  
	 * @Title findTCMmExcelTemplateByContractCode
	 * @Description TODO
	 * @param contractCode
	 * @return
	 * @throws Exception 
	 * TCMmExcelTemplateDTO 
	 * @date 2015-2-6-下午6:31:42
	 * @update 
	 * @throws
	 */
	public TCMmExcelTemplateDTO findTCMmExcelTemplateByContractCodeNotDto(Map<String,Object> searchParams) throws Exception {
		
		TCMmExcelTemplateDTO dto = dao.findTCMmExcelTemplateByContractCodeNotDto(searchParams);
		
		if(dto == null) dto = new TCMmExcelTemplateDTO();
		
		return dto;
		
	}
	
	/**
	 *  查询数据字典code
	 * @Title findDictCodeByContractCode
	 * @Description TODO
	 * @return
	 * @throws Exception 
	 * @update 
	 * @throws
	 */
	public Map<String,String> findDictCodeByContractCode(Map<String,Object> searchParams) throws Exception {
		
		Map<String,String> dto = dao.findDictCodeByContractCode(searchParams);
		
		if(dto == null) dto = new HashMap<String,String>();
		
		return dto;
	
	}
	/**
     * @title: insertTCMmExcelTemplate
     * @author JY-IT-D001
     * @description: 新增 T_C_MM_EXCEL_TEMPLATE对象
     * @date 2015-01-06 17:32:59
     * @param dto
     * @return
     * @throws
     */
	@SuppressWarnings("all")
	public Long insertTCMmExcelTemplate(TCMmExcelTemplateDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		int count = dao.insertTCMmExcelTemplate(paramMap);
		
		TCMmExcelTemplateDTO resultDto = (TCMmExcelTemplateDTO) paramMap.get("dto");
		Long keyId = resultDto.getId();
		return keyId;
	}
	/**
     * @title: updateTCMmExcelTemplate
     * @author JY-IT-D001
     * @description: 修改 T_C_MM_EXCEL_TEMPLATE对象
     * @date 2015-01-06 17:32:59
     * @param paramMap
     * @return
     * @throws
     */
	public void updateTCMmExcelTemplate(TCMmExcelTemplateDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		dao.updateTCMmExcelTemplate(paramMap);
	}
	/**
     * @title: deleteTCMmExcelTemplateByPrimaryKey
     * @author JY-IT-D001
     * @description: 删除 T_C_MM_EXCEL_TEMPLATE,按主键
     * @date 2015-01-06 17:32:59
     * @param paramMap
     * @throws
     */ 
	public void deleteTCMmExcelTemplateByPrimaryKey(BaseDTO baseDto,String ids) throws Exception {
		if(StringUtils.isEmpty(ids)) throw new Exception("删除失败！传入的参数主键为null");
		
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", baseDto);
		paramMap.put("ids", ids);
		dao.deleteTCMmExcelTemplateByPrimaryKey(paramMap);
	}
}

